<template>
	<view class="login pages">
		<view class="nav">
			<uni-icons type="closeempty" size="24" @click="back"></uni-icons>
			<view style="color: grey;"></view>
		</view>
		<view class="body">
			<view class="form">
				<view class="form_title">{{$t('login.newPassword.Reset')}}</view>
				<view class="form_text">{{$t('login.newPassword.Please')}}</view>
				<view class="form_input">
					<input v-if="eye" type="password" :placeholder="$t('login.newPassword.New')" v-model="form.password" style="margin-left: 0;">
					<input v-else type="text" :placeholder="$t('login.newPassword.New')" v-model="form.password" style="margin-left: 0;">
					<uni-icons :type="eye?'eye-filled':'eye-slash-filled'" color="grey" size="18" @click="eye=!eye"></uni-icons>
				</view>
			</view>
			<view class="btn">
				<view @click="indexForgetPass">{{$t('login.newPassword.Confirm')}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { indexForgetPass } from '@/api/api.js'
	export default {
		data() {
			return {
				eye: true,
				form: {}
			};
		},
		onLoad(option) {
			this.form = JSON.parse(option.form)
		},
		methods: {
			back() {
				uni.navigateBack()
			},
			indexForgetPass(){
				indexForgetPass({
					phone: this.form.phone,
					code: this.form.code,
					new_pass: this.form.password
				}).then(res=>{
					uni.showToast({
						title: res.data.msg,
						icon: "none"
					})
					setTimeout(() => {
						uni.reLaunch({
							url: "/pages/shop/login/other"
						})
					}, 500)
				})
			}
		}
	}
</script>

<style lang="scss">
	/deep/.uni-input-placeholder {
		font-size: 28rpx;
		font-weight: normal;
	}

	.login {
		padding: 10px;
		box-sizing: border-box;
		font-size: 30rpx;
	}

	.nav {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.body {
		width: 90%;
		margin: 0 auto;

		.form {
			margin: 140rpx auto 60rpx;

			.form_title {
				font-size: 46rpx;
			}

			.form_text {
				color: gray;
				margin: 20rpx 0 30rpx;
			}

			.form_input {
				display: flex;
				justify-content: space-between;
				align-items: center;
				border-bottom: 1px solid #ddd;
				height: 80rpx;
				margin-top: 30rpx;

				input {
					flex-grow: 1;
					margin-left: 30rpx;
					font-weight: bold;
					font-size: 40rpx;
				}
			}
		}

		.btn {
			&>view {
				height: 90rpx;
				line-height: 90rpx;
				text-align: center;
				border-radius: 6rpx;
				margin-bottom: 20rpx;
			}

			&>view:first-child {
				background-color: #00C2C2;
				color: #fff;
			}
		}
	}

</style>